<div class="contentArea" ng-app="myApp" ng-controller="myController">
    <div class="Item hr">
        <div class="current">文章详情</div>
    </div>
    <form>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
            <tr>
                <th width="80">文章名称：</th>
                <td><input name="data[title]" type="text" class="input" size="30" value="{$article['title']}" /></td>
            </tr>
            <tr>
                <th width="80">文章简介：</th>
                <td><textarea class="jq_watermark" rows = "5" cols="68" name="data[intro]">{$article['intro']}</textarea></td>
            </tr>

            <tr>
                <th width="90">文章图片：</th>
                <td>
                    <img src="{$article.pic}" style="width: 600px;height: 280px;" /></br></br>
                    <input type="file" id="pic" name="pic">
                </td>
            </tr>

            <tr id="show_novel">
                <th width="80">对应小说：</th>
                <td><input readonly type="text" class="input" size="30" name="data[novel_id]" value="{$article['novel_name']}" /><a ng-click="alert_novel()" href="javascript:void(0);">修改</a></td>
            </tr>

            <tr id="select_novel" style="display: none">
                <th width="90">选择小说：</th>
                <td>
                    <input style="height: 30px;" ng-model="data.keyword" placeholder="&nbsp;请输入要搜索的小说名称"><input style="width: 50px; height: 30px;margin-left: 10px;" type='button' id="submit_novel" ng-click="search_novel();" value='搜索'>
                    <select ng-model="data.novel_id" style="width: 235px;margin-top: 10px;display: none;" id="show_novel_list" name="data[novel_id]">
                        <option value="" selected>请选择小说</option>
                        <option ng-repeat="item in novel_list" value="{{item.id}}">{{item.title}}</option>
                    </select>
                </td>
            </tr>

            <input type="hidden" name="data[id]" value="{$article['id']}" />
        </table>
    </form>
    <div class="commonBtnArea" >
        <button class="btn submit">提交</button>
    </div>

</div>

<script type="text/javascript" src="__PUBLIC__/javascripts/admin/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/javascripts/admin/angular.min.js"></script>

<script type="text/javascript">
    var app = angular.module('myApp',[]);
    app.controller('myController',function($scope){
        $scope.data = {keyword:''};
        $scope.novel_list = [{id:'',title:''}];     //小说列表

        $scope.alert_novel = function(){
            $('#show_novel').hide();
            $('#select_novel').show();

            //搜索小说
            $scope.search_novel = function(){
                if($scope.data.keyword == ''){
                    layer.alert("请输入搜索内容",{icon:2});return false;
                }

                $.post("{:U('Novel/search_novels')}",{keyword:$scope.data.keyword},function(data){
                    if(data.code == 0){
                        $('#show_novel_list').show();
                        $scope.$apply(function(){
                            $scope.novel_list = data.list;
                        })
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },'json')
            }
        }

        $(".submit").click(function(){
            commonAjaxSubmit("{:U('Article/update')}");
        });
    });


</script>

